package com.itheima.Day11.Huanchong;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

public class Test {
    public static void main(String[] args) {
        try(FileReader fr = new FileReader("D:\\javajc_ws\\javaEE\\src\\com\\itheima\\Day11\\Huanchong\\anli.txt");
            FileWriter fw = new FileWriter("D:\\javajc_ws\\javaEE\\src\\com\\itheima\\Day11\\Huanchong\\anli2.txt");
        BufferedReader br = new BufferedReader(fr);
        BufferedWriter bw = new BufferedWriter(fw);){
            String line ;
            ArrayList<String> list = new ArrayList<>();
            while ((line = br.readLine()) != null){
                list.add(line);
            }
            Collections.sort( list);
            for (String s : list) {
                bw.write(s);
                bw.newLine();
                bw.flush();
            }

        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }
    }
